import { managementService } from '~/config/server';
import { NetService } from '~/utils/net.service';
import { Inject, Debounce } from '~/core/decorator';

export class StrategyConfigService {
  @Inject(NetService)
  private netService: NetService;

  /**
   * 获取支持的策略字段
   */
  public getStrategyFields() {
    return this.netService.send({
      server: managementService.strategyConfigController.getStrategyFields
    });
  }

  /**
   * 创建策略
   */
  @Debounce()
  public createStrategy(data) {
    return this.netService.send({
      server: managementService.strategyConfigController.createStrategy,
      data,
      loading: true
    });
  }

  /**
   * 修改策略
   */
  @Debounce()
  public updateStrategy(data) {
    return this.netService.send({
      server: managementService.strategyConfigController.updateStrategy,
      data,
      loading: true
    });
  }

  /**
   * 分页查询策略
   */
  public queryStrategyConfigPage(data, page) {
    return this.netService.send({
      server: managementService.strategyConfigController.queryStrategyConfigPage,
      data,
      page
    });
  }
  /**
   * 通过ID获取策略
   * @param data 
   */
  public getOneById(id) {
    return this.netService.send({
      server: managementService.strategyConfigController.getOneById,
      data:{
        id
      }
    });
  }

  /**
   * 通过ID删除策略
   * @param data 
   */
  public delete(id) {
    return this.netService.send({
      server: managementService.strategyConfigController.delete,
      data:{
        id
      }
    });
  }

}
